<template>
    <view>
        <view class="topbar" :style="'--color:' + color + ';--rgbcolor:' + rgbcolor">
            <text @tap="topbarFn" :class="'item ' + (currentTab == index ? 'active' : '')" :data-idx="index" v-for="(item, index) in topbar" :key="index">{{ item }}</text>
        </view>
        <view class="nodata" v-if="LIST.length == 0">
            <image mode="aspectFit" src="/static/res/img/nodata.png"></image>
            暂无信息
        </view>
        <view class="my_huhuan">
            <view class="dl" v-for="(item, list_index) in LIST" :key="list_index">
                <view @tap="uFn" class="dt" :data-uid="item.uid">
                    <image mode="aspectFill" :src="item.photo_s_url"></image>
                </view>

                <view class="dd">
                    <view class="h4">
                        <image class="ugrade1" mode="aspectFill" :src="item.grade_ico"></image>
                        {{ item.nickname }}
                    </view>
                    <view class="h6">
                        <view @tap="copyFn" :data-content="item.content" :data-kind_str="item.kind_str" v-if="item.ifagree == 1">
                            <text class="ico"> 复制</text>
                            {{ item.kind_str }}：
                            <text style="color: #000">{{ item.content }}</text>
                        </view>
                        <block v-else>{{ item.uinfo }}</block>
                    </view>
                </view>

                <button :class="item.class" style="line-height: 200%; height: auto" type="button" v-if="currentTab == 0">
                    <view class="i ico">{{ item.kind == 'mob' ? '' : '' }}</view>
                    {{ item.flag_str }}
                </button>

                <block v-if="currentTab == 1">
                    <block v-if="item.ifagree == 0">
                        <view class="kind_str">想与你互换{{ item.kind_str }}</view>
                        <button @tap="agreeFn" class="agree_btn" :data-kind="item.kind" :data-list_index="list_index" :data-uid="item.uid" type="button">同意</button>
                        <button @tap="passFn" class="pass_btn" :data-kind="item.kind" :data-list_index="list_index" :data-uid="item.uid" type="button">拒绝</button>
                    </block>
                    <button :class="item.class" style="line-height: 200%; height: auto" type="button" v-else>
                        <view class="i ico">{{ item.kind == 'mob' ? '' : '' }}</view>
                        {{ item.flag_str }}
                    </button>
                </block>

                <button :class="item.class" style="line-height: 200%; height: auto" type="button" v-if="currentTab == 2">
                    <view class="i ico">{{ item.kind == 'mob' ? '' : '' }}</view>
                    {{ item.flag_str }}
                </button>
            </view>
        </view>
        <view @tap="mask_closeFn" :class="'mask3 ' + mask_class" data-maskid="div_vip" v-if="div_vip">
            <view @tap.stop.prevent="emptyFn" class="div_box div_vip" style="--div_box_width: 600rpx; --div_box_height: 480rpx">
                <view @tap.stop.prevent="mask_closeFn" class="closebtm ico" data-maskid="div_vip"></view>
                <view class="h1">{{ div_vip_title }}</view>
                <view class="C S15">开通VIP超级会员，专享超值权益</view>
                <view class="C S15">相亲成功率提升300%</view>
                <view class="ico picico"></view>
                <view @tap.stop.prevent="vipFn" class="btn_btm btn44 ico"> 立即升级</view>
            </view>
        </view>
        <view @tap="mask_closeFn" :class="'mask3 ' + mask_class" data-maskid="div_cert" v-if="div_cert">
            <view @tap.stop.prevent="emptyFn" class="div_box div_cert" style="--div_box_width: 600rpx; --div_box_height: 480rpx">
                <view @tap.stop.prevent="mask_closeFn" class="closebtm ico" data-maskid="div_cert"></view>
                <view class="h1">{{ div_cert_title }}</view>
                <view class="C S15">成为认证用户，即享沟通特权</view>
                <view class="C S15">提高诚信值，杜绝虚假</view>
                <view class="ico picico"></view>
                <view @tap.stop.prevent="certFn" class="btn_btm btn44 ico">立即认证</view>
            </view>
        </view>
        <view @tap="mask_closeFn" :class="'mask3 ' + mask_class" data-maskid="div_data" v-if="div_data">
            <view @tap.stop.prevent="emptyFn" class="div_box div_data" :style="'--div_box_width:600rpx;--div_box_height:480rpx;--color:' + color + ';--rgbcolor:' + rgbcolor">
                <view @tap.stop.prevent="mask_closeFn" class="closebtm ico" data-maskid="div_data"></view>
                <view class="h1">{{ div_data_title }}</view>
                <view class="C S15">赶快去完善，解锁更多功能</view>
                <view class="C S15">完成资料，上传头像，受关注度暴增</view>
                <view class="ico picico"></view>
                <view @tap.stop.prevent="dataFn" class="btn_btm btn44 ico">立即完善</view>
            </view>
        </view>
        <view @tap="mask_closeFn" :class="'mask3 ' + mask_class" data-maskid="div_hh_box" v-if="div_hh_box">
            <view @tap.stop.prevent="emptyFn" class="div_box div_hh_box" :style="'--div_box_width:600rpx;--div_box_height:520rpx;--color:' + color + ';--rgbcolor:' + rgbcolor">
                <view @tap.stop.prevent="mask_closeFn" class="closebtm ico" data-maskid="div_data"></view>
                <view class="ico picico"></view>
                <view class="h1">和Ta互换{{ hh_title }}</view>
                <form @submit="hh_submitFn" :data-hh_kind="hh_kind" :data-hh_uid="hh_uid">
                    <view class="inputbox">
                        <text :class="'i ico ' + (hh_kind == 'weixin' ? 'wxi' : 'mobi')">{{ hh_kind == 'weixin' ? '' : '' }}</text>
                        <input confirmType="完成" maxlength="30" name="content" :placeholder="'请输入' + hh_title" type="text" :value="hh_kind == 'weixin' ? MY.wx : MY.mb" />
                    </view>
                    <view class="em">
                        确保您本人【{{ hh_title }}】必须真实有效，否则将纳入失信人员名单并进行
                        <text class="Cf00">封号处理</text>
                    </view>
                    <button class="btn_btm btn44 ico" formType="submit"> 同意并发送</button>
                </form>
            </view>
        </view>
        <view @tap="mask_closeFn" :class="'mask3 ' + mask_class" data-maskid="div_hh_success" v-if="div_hh_success">
            <view
                @tap.stop.prevent="emptyFn"
                class="div_box div_hh_box small_big"
                :style="'--div_box_width:600rpx;--div_box_height:430rpx;--color:' + color + ';--rgbcolor:' + rgbcolor"
            >
                <view @tap.stop.prevent="mask_closeFn" class="closebtm ico" data-maskid="div_hh_success"></view>
                <view class="ico picico"></view>
                <view class="h1 C090 ico"> 互换成功</view>
                <view class="C S15 ico" style="margin-top: 30rpx; text-align: left">Ta的{{ hh_title }}：{{ HH.senduid_content }}</view>
                <button @tap="copyFn" class="btn_btm btn44 ico" :data-content="HH.senduid_content" :data-kind_str="hh_title"> 复制{{ hh_title }}</button>
            </view>
        </view>
    </view>
</template>

<script>
var t = require('../../@babel/runtime/helpers/defineProperty');
var a = require('../../res/www.a9a.cn.js');
var app = getApp();
var n = uni.getStorageSync('COOK_U');
export default {
    data() {
        return {
            topbar: ['我发起的', '收到请求', '互换成功'],
            currentTab: 0,
            LIST_index: 0,
            color: '',
            rgbcolor: '',
            LIST: '',

            MY: {
                wx: '',
                mb: ''
            },

            mask_class: '',
            div_hh_box: false,
            hh_title: '',
            hh_kind: '',
            hh_uid: '',
            list_index: '',
            div_login: false,
            div_vip: '',
            div_vip_title: '',
            div_cert: '',
            div_cert_title: '',
            div_data: '',
            div_data_title: '',
            div_hh_success: '',

            HH: {
                senduid_content: ''
            }
        };
    },
    onLoad: function (t) {
        var n = t.t;
        n = a.empty(n) ? 1 : n;
        this.setData({
            currentTab: n - 1
        });
        var that = this;
        app.globalData.chklogin().then(function (t) {
            t || uni.navigateBack();
        });
        app.globalData.get_openid().then(function (t) {
            that.setData({
                color: app.globalData._ZEAI.color,
                rgbcolor: a.c16_rgb(app.globalData._ZEAI.color)
            });
            that.get_data(n);
        });
    },
    methods: {
        topbarFn: function (t) {
            var a = parseInt(t.currentTarget.dataset.idx);
            this.setData({
                currentTab: a
            });
            this.get_data(a + 1);
        },

        get_data: function (t) {
            var that = this;
            n = uni.getStorageSync('COOK_U');
            app.globalData.ajax({
                url: 'my_hh.php',
                data: {
                    submitok: 'list',
                    t: t,
                    openid: n.openid
                },
                success: function (t) {
                    1 == t.flag
                        ? that.setData({
                              LIST: t.LIST,
                              MY: t.MY
                          })
                        : uni.showModal({
                              content: t.msg,
                              confirmColor: that.color,
                              confirmText: '朕知道了',
                              showCancel: false,
                              success: function (t) {
                                  uni.navigateBack();
                              }
                          });
                }
            });
        },

        uFn: function (t) {
            var a = t.currentTarget.dataset.uid;
            uni.navigateTo({
                url: '/pagesA/u/u?uid=' + a
            });
        },

        copyFn: function (t) {
            var e = t.currentTarget.dataset.content;
            var n = t.currentTarget.dataset.kind_str;
            a.copy_text({
                data: e,
                msg: n + '复制成功'
            });
        },

        agreeFn: function (t) {
            var a = t.currentTarget.dataset.uid;
            var e = t.currentTarget.dataset.kind;
            var n = t.currentTarget.dataset.list_index;
            var i = 'weixin' == e ? '微信号' : '手机号';
            this.setData({
                mask_class: 'alpha0_100',
                div_hh_box: true,
                hh_title: i,
                hh_kind: e,
                hh_uid: a,
                list_index: n
            });
        },

        passFn: function (a) {
            var i = a.currentTarget.dataset.uid;
            var s = a.currentTarget.dataset.kind;
            var r = a.currentTarget.dataset.list_index;
            var o = 'weixin' == s ? '微信号' : '手机号';
            var that = this;
            uni.showModal({
                title: '拒绝互换',
                content: '缘份就在一瞬间\n\n确定要【拒绝】互换' + o + '么？',
                confirmColor: that.color,
                cancelText: '取消',
                confirmText: '确定',
                success: function (a) {
                    if (a.confirm) {
                        app.globalData.ajax({
                            url: 'my_hh.php',
                            data: {
                                submitok: 'ajax_pass',
                                kind: s,
                                uid: i,
                                openid: n.openid
                            },
                            success: function (a) {
                                var e;
                                1 == a.flag
                                    ? that.setData(
                                          (t((e = {}), 'LIST[' + r + '].ifagree', 2), t(e, 'LIST[' + r + '].class', 'pass'), t(e, 'LIST[' + r + '].flag_str', '已拒绝'), e)
                                      )
                                    : uni.showToast({
                                          title: a.msg,
                                          icon: 'none',
                                          mask: true,
                                          duration: 4000
                                      });
                            }
                        });
                    }
                }
            });
        },

        hh_submitFn: function (i) {
            var s = i.currentTarget.dataset.hh_uid;
            var r = i.currentTarget.dataset.hh_kind;
            var o = i.detail.value.content;
            var c = 'weixin' == r ? '微信号' : '手机号';
            var that = this;
            a.empty(o)
                ? uni.showToast({
                      title: '请输入【' + c + '】',
                      icon: 'none',
                      mask: true
                  })
                : 'mob' != r || a.ifmob(o)
                ? (this.setData({
                      div_hh_box: false,
                      hh_title: c
                  }),
                  app.globalData.ajax({
                      url: 'my_hh.php',
                      data: {
                          submitok: 'ajax_hh_update',
                          content: o,
                          kind: r,
                          uid: s,
                          openid: n.openid
                      },
                      success: function (e) {
                          if (1 == e.flag) {
                              var n;
                              var i = that.list_index;
                              that.setData(
                                  ((n = {
                                      HH: e.HH,
                                      mask_class: 'alpha0_100',
                                      div_hh_success: true
                                  }),
                                  t(n, 'LIST[' + i + '].ifagree', 1),
                                  t(n, 'LIST[' + i + '].class', 'success'),
                                  t(n, 'LIST[' + i + '].flag_str', '互换成功'),
                                  n)
                              );
                          } else {
                              e.this = that;
                              a.sorry(e);
                          }
                      }
                  }))
                : uni.showToast({
                      title: '请输入正确的【' + c + '】',
                      icon: 'none',
                      mask: true
                  });
        },

        certFn: function () {
            var that = this;
            app.globalData.chklogin().then(function (a) {
                a
                    ? uni.navigateTo({
                          url: '/myPages/cert/cert'
                      })
                    : that.setData({
                          div_login: true
                      });
            });
        },

        vipFn: function () {
            var that = this;
            app.globalData.chklogin().then(function (a) {
                a
                    ? uni.navigateTo({
                          url: '/pagesA/my_vip/my_vip'
                      })
                    : that.setData({
                          div_login: true
                      });
            });
        },

        dataFn: function () {
            var that = this;
            app.globalData.chklogin().then(function (a) {
                a
                    ? uni.navigateTo({
                          url: '/pagesA/reg/reg'
                      })
                    : that.setData({
                          div_login: true
                      });
            });
        },

        mask_closeFn: function (a) {
            var that = this;
            var n = a.currentTarget.dataset.maskid;
            this.setData({
                mask_class: 'alpha100_0'
            });
            setTimeout(function () {
                that.setData(t({}, n, false));
            }, 500);
        },

        emptyFn() {
            console.log('占位：函数 emptyFn 未声明');
        }
    }
};
</script>
<style>
@import 'hh.css';
</style>
